using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Logic.Agglomerative 
{
    public class Node : IComparable
    {
        private int i, j;
        private double key;

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="i"></param>
        /// <param name="j"></param>
        /// <param name="key"></param>
        public Node(int i, int j, double key)
        {
            this.i = i;
            this.j = j;
            this.key = key;
        }

        #endregion

        #region Properties

        public int I
        {
            get { return i; }
        }

        public int J
        {
            get { return j; }
        }

        public double Key
        {
            get { return key; }
        }
        
        #endregion

        #region Inner classes

        /// <summary>
        /// inner class to help with sort nodes according to their I index instead of their key
        /// </summary>
        public class sortyByIndexI : IComparer
        {
            #region IComparer Members

            int IComparer.Compare(object a, object b)
            {
                Node node1 = (Node)a;
                Node node2 = (Node)b;

                if (node1.i > node2.i)
                    return 1;

                if (node1.i < node2.i)
                    return -1;
                return 0;
            }

            #endregion
        }

        #endregion

        #region IComparable Members

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            if (this.key < ((Node)obj).Key)
                return -1;
            if (this.key > ((Node)obj).Key)
                return 1;
            return 0;
        }

        #endregion
    }
}
